home *** CD-ROM | disk | FTP | other *** search
/ Champak 128 / Vol 128 (Damaged).iso / games / cake_fab.swf / scripts / frame_12 / DoAction.as
Encoding:
Text File  |  2011-03-26  |  11.4 KB  |  437 lines

  1. function gameStart()
  2. {
  3.    cakeListing();
  4.    pt.cakenum.gotoAndStop(ccnt + 1);
  5.    var _loc1_ = 0;
  6.    while(_loc1_ < itemnum)
  7.    {
  8.       cakeColor[_loc1_] = 0;
  9.       cakeColor2[_loc1_] = 0;
  10.       _loc1_ = _loc1_ + 1;
  11.    }
  12.    initSet();
  13. }
  14. function cakeCopy()
  15. {
  16.    if(ccnt < itemnum)
  17.    {
  18.       _root.cakeMc.cake.duplicateMovieClip("cake" + copynum,copynum);
  19.       _root.cakeMc["cake" + copynum]._alpha = 100;
  20.       _root.cakeMc["cake" + copynum]._x = 0;
  21.       _root.cakeMc["cake" + copynum]._y = 0;
  22.       _root.cakeMc["cake" + copynum].gotoAndPlay("start");
  23.       _root.cakeMc["cake" + copynum].cake.deco2._visible = false;
  24.       _root.cakeMc["cake" + copynum].cake.deco3._visible = false;
  25.       _root.cakeMc["cake" + copynum].cake.deco1.gotoAndStop(1);
  26.       _root.cakeMc["cake" + copynum].cake.deco2.gotoAndStop(1);
  27.       _root.cakeMc["cake" + copynum].cake.deco3.gotoAndStop(1);
  28.       _root.cakeMc["cake" + copynum].coner = 0;
  29.       _root.cakeMc["cake" + copynum].num = copynum;
  30.       stepArr[copynum] = [];
  31.       stepArr[copynum][0] = 1;
  32.       _root.cakeMc["cake" + copynum].onEnterFrame = function()
  33.       {
  34.          if(this.coner == 0)
  35.          {
  36.             if(this._y >= 111)
  37.             {
  38.                this.coner = 1;
  39.                this._y = 111;
  40.             }
  41.             else
  42.             {
  43.                this._y += 10;
  44.             }
  45.          }
  46.          else if(this._y == 111 and this.coner == 1)
  47.          {
  48.             if(this._x >= 333)
  49.             {
  50.                this._x = 333;
  51.                this.coner = 2;
  52.             }
  53.             else
  54.             {
  55.                this._x += cakesp;
  56.             }
  57.          }
  58.          else if(this._x >= 333 and this.coner == 2)
  59.          {
  60.             if(this._x >= 426 and this._y >= 325)
  61.             {
  62.                this.coner = 3;
  63.                this._x = 426;
  64.                this._y = 325;
  65.             }
  66.             else
  67.             {
  68.                this._x += cakesp / 3;
  69.                this._y += cakesp / 1.5;
  70.             }
  71.          }
  72.          else if(this._x <= 426 and this.coner == 3)
  73.          {
  74.             if(this._x <= -44)
  75.             {
  76.                this.coner = 4;
  77.                this._x = -44;
  78.                postCake(this.num);
  79.             }
  80.             else
  81.             {
  82.                this._x -= cakesp;
  83.             }
  84.          }
  85.          if(this.hitTest(_root.m2.area))
  86.          {
  87.             this.cake.deco1.gotoAndStop(2);
  88.             stepArr[this.num][1] = 1;
  89.             trace("making-step2-success/" + stepArr[this.num][1]);
  90.          }
  91.          if(this.hitTest(_root.m3.area) and this.cake.deco1._currentframe == 2 and _root.mm3 == true)
  92.          {
  93.             this.cake.deco1.gotoAndStop(_root.m3num + 2);
  94.             if(_root.m3num == cakeArr[this.num])
  95.             {
  96.                stepArr[this.num][2] = 1;
  97.                trace("making-step3-success");
  98.             }
  99.             else
  100.             {
  101.                stepArr[this.num][2] = 0;
  102.                trace("making-step3-fail");
  103.             }
  104.          }
  105.          if(this.hitTest(_root.m4.area) and this.cake.deco1._currentframe >= 2 and _root.mm4 == true)
  106.          {
  107.             if(_root.m4num == cakeArr[this.num])
  108.             {
  109.                stepArr[this.num][3] = 1;
  110.                trace("making-step4-success");
  111.             }
  112.             else
  113.             {
  114.                stepArr[this.num][3] = 0;
  115.                trace("making-step4-fail");
  116.             }
  117.             this.cake.deco2._visible = true;
  118.             this.cake.deco2.gotoAndStop(_root.m4num);
  119.             this.cake.deco2.ck.gotoAndPlay(1);
  120.          }
  121.          if(this.hitTest(_root.m5.area) and this.cake.deco1._currentframe >= 2 and _root.mm5 == true)
  122.          {
  123.             if(_root.m5num == cakeArr[this.num])
  124.             {
  125.                stepArr[this.num][4] = 1;
  126.                trace("making-step5-success");
  127.             }
  128.             else
  129.             {
  130.                stepArr[this.num][4] = 0;
  131.                trace("making-step5-fail");
  132.             }
  133.             this.cake.deco3._visible = true;
  134.             this.cake.deco3.gotoAndStop(_root.m5num);
  135.          }
  136.       };
  137.       trace("copy : " + copynum);
  138.       copynum++;
  139.    }
  140.    else if(ccnt == _root.itemnum)
  141.    {
  142.       gameover();
  143.    }
  144. }
  145. function postCake(num)
  146. {
  147.    delete _root.cakeMc["cake" + num].onEnterFrame;
  148.    cakeCheck(num);
  149. }
  150. function cakeListing()
  151. {
  152.    var _loc1_ = 0;
  153.    while(_loc1_ < 50)
  154.    {
  155.       pt.cakeList.removeMovieClip();
  156.       _loc1_ = _loc1_ + 1;
  157.    }
  158.    _loc1_ = 0;
  159.    while(_loc1_ < 50)
  160.    {
  161.       pt.cakeList.attachMovie("cg","cg" + _loc1_,_loc1_);
  162.       var _loc2_ = random(4) + 1;
  163.       cakeArr[_loc1_] = _loc2_;
  164.       pt.cakeList["cg" + _loc1_].gotoAndStop(_loc2_);
  165.       pt.cakeList["cg" + _loc1_]._x = _loc1_ * 80 + 10;
  166.       pt.cakeList["cg" + _loc1_].tx = _loc1_ * 80 + 10 - gcnt * 80;
  167.       _loc1_ = _loc1_ + 1;
  168.    }
  169.    trace(cakeArr);
  170. }
  171. function cakeListMove()
  172. {
  173.    trace("∞¥┤δÅÖ : " + gcnt);
  174.    gameSound("list");
  175.    var _loc2_ = 0;
  176.    while(_loc2_ < 50)
  177.    {
  178.       pt.cakeList["cg" + _loc2_].tx = _loc2_ * 80 + 10 - gcnt * 80;
  179.       pt.cakeList["cg" + _loc2_].onEnterFrame = function()
  180.       {
  181.          this._x += (this.tx - this._x) * 0.5;
  182.       };
  183.       _loc2_ = _loc2_ + 1;
  184.    }
  185.    delete pt.cakeList["cg" + (gcnt - 1)].onEnterFrame;
  186.    pt.cakeList["cg" + (gcnt - 1)]._visible = false;
  187. }
  188. function initSet()
  189. {
  190.    trace("∞ï£∞₧æ:" + gcnt);
  191.    pt.m_start._visible = true;
  192.    pt.m_start.gotoAndPlay(2);
  193.    if(ccnt == itemnum)
  194.    {
  195.       _root.point = ccnt;
  196.       gameover();
  197.    }
  198.    else
  199.    {
  200.       cakeListMove();
  201.    }
  202. }
  203. function cakeCheck(num)
  204. {
  205.    trace(stepArr[num]);
  206.    var _loc3_ = 0;
  207.    var _loc2_ = 0;
  208.    while(_loc2_ < 5)
  209.    {
  210.       if(stepArr[num][_loc2_] == 1)
  211.       {
  212.          _loc3_ = _loc3_ + 1;
  213.       }
  214.       _loc2_ = _loc2_ + 1;
  215.    }
  216.    if(_loc3_ == 5)
  217.    {
  218.       trace("success - " + cakeArr[gcnt]);
  219.       pt.cake_result.gotoAndStop(cakeArr[gcnt] + 1);
  220.       pt.cakeList["cg" + gcnt]._visible = false;
  221.       ccnt++;
  222.       pt.cakenum.gotoAndStop(ccnt + 1);
  223.       _root.cakeMc["cake" + num]._visible = false;
  224.       gameSound("success");
  225.    }
  226.    else
  227.    {
  228.       trace("failure - " + _loc3_);
  229.       _root.cakeMc["cake" + num].gotoAndPlay("fail");
  230.       gameSound("failure");
  231.    }
  232.    if(ccnt == itemnum)
  233.    {
  234.       _root.point = ccnt;
  235.       _root.game_overstate = true;
  236.    }
  237.    gcnt++;
  238.    cakeListMove();
  239. }
  240. function boxfunc(num)
  241. {
  242.    cakeColor[ccnt - 1] = 1;
  243.    cakeColor2[ccnt - 1] = num;
  244.    pt.box["b" + ccnt]._visible = true;
  245.    pt.box["b" + ccnt].gotoAndStop(num);
  246.    trace("box - " + ccnt + "/" + cakeColor[ccnt - 1] + "/" + cakeColor2[ccnt - 1]);
  247. }
  248. function gameSound(nme)
  249. {
  250.    switch(nme)
  251.    {
  252.       case "list":
  253.          startSound = new Sound();
  254.          startSound.attachSound("snd_list");
  255.          startSound.setVolume(100);
  256.          startSound.start();
  257.          break;
  258.       case "clock":
  259.          var _loc1_ = new Sound();
  260.          _loc1_.attachSound("clock");
  261.          _loc1_.setVolume(100);
  262.          _loc1_.start(0,10);
  263.          break;
  264.       case "success":
  265.          startSound = new Sound();
  266.          startSound.attachSound("snd_success");
  267.          startSound.setVolume(100);
  268.          startSound.start();
  269.          break;
  270.       case "failure":
  271.          startSound = new Sound();
  272.          startSound.attachSound("snd_failure");
  273.          startSound.setVolume(100);
  274.          startSound.start();
  275.          break;
  276.       case "bgm":
  277.          startSound = new Sound();
  278.          startSound.attachSound("bgm");
  279.          startSound.setVolume(100);
  280.          startSound.start(0,999);
  281.    }
  282. }
  283. function gameover()
  284. {
  285.    trace("cristal number : " + ccnt);
  286.    _root.point = ccnt;
  287.    pt.gotoAndPlay("over");
  288. }
  289. function getXmlData()
  290. {
  291.    trace("-----------------------------------------------");
  292.    trace("Ω▓î∞₧ä∞¥ä ∞£äφò£ ∞┤êΩ╕░ xml δí£δô£");
  293.    trace("-----------------------------------------------");
  294.    var _loc2_ = undefined;
  295.    var _loc3_ = undefined;
  296.    var _loc4_ = xmldoc.firstChild.firstChild;
  297.    while(_loc4_ != null)
  298.    {
  299.       _loc2_ = _loc4_.nodeName;
  300.       _loc3_ = _loc4_.firstChild.nodeValue;
  301.       if(_loc2_ == "allowDomain")
  302.       {
  303.          allowDomain = _loc3_;
  304.          trace("domain:" + allowDomain);
  305.       }
  306.       else if(_loc2_ == "configfile")
  307.       {
  308.          _root.configfile = _loc3_;
  309.          trace("configfile:" + _root.configfile);
  310.       }
  311.       else if(_loc2_ == "updatefile")
  312.       {
  313.          _root.updatefile = _loc3_;
  314.          trace("updatefile:" + _root.updatefile);
  315.       }
  316.       else if(_loc2_ == "loginfile")
  317.       {
  318.          _root.loginfile = _loc3_;
  319.          trace("loginfile:" + _root.loginfile);
  320.       }
  321.       else if(_loc2_ == "cristal")
  322.       {
  323.          cristal = _loc3_;
  324.          trace("cirstal:" + cristal);
  325.       }
  326.       else if(_loc2_ == "popmsg")
  327.       {
  328.          popmsg = _loc3_;
  329.          trace("popmsg:" + popmsg);
  330.       }
  331.       _loc4_ = _loc4_.nextSibling;
  332.    }
  333.    _root.cristalpoint = cristal.split(",");
  334.    _root.popmessage = popmsg.split(",");
  335.    trace("-----------------------------------------------");
  336. }
  337. function dbCon(filename)
  338. {
  339.    dbs = new LoadVars();
  340.    dbs.onLoad = function(success)
  341.    {
  342.       pt.loginstate = dbs.loginstate;
  343.       if(success)
  344.       {
  345.          trace("database connect success!! - " + pt.loginstate);
  346.          if(pt.loginstate != "Y")
  347.          {
  348.             getURL(loginfile,"");
  349.          }
  350.       }
  351.       else
  352.       {
  353.          trace("database connect  failure!!");
  354.          getURL(loginfile,"");
  355.       }
  356.    };
  357.    randoms = Math.random();
  358.    dbs.load(filename + "?rnd=" + randoms + "&gameid=" + _root.gameid);
  359. }
  360. function cristalvalue(point)
  361. {
  362.    var _loc3_ = _root.cristalpoint.length;
  363.    var _loc2_ = 0;
  364.    while(_loc2_ < _loc3_)
  365.    {
  366.       if(_loc2_ <= _loc3_ - 2)
  367.       {
  368.          if(point > int(_root.cristalpoint[_loc2_]) and point <= int(_root.cristalpoint[_loc2_ + 1]))
  369.          {
  370.             cristalnum = _loc2_;
  371.             break;
  372.          }
  373.       }
  374.       else if(_loc2_ == _loc3_ - 1)
  375.       {
  376.          if(point > int(_root.cristalpoint[_loc2_]))
  377.          {
  378.             cristalnum = _loc2_;
  379.             break;
  380.          }
  381.       }
  382.       _loc2_ = _loc2_ + 1;
  383.    }
  384.    cristalmessage(cristalnum);
  385.    _root.msgnum = cristalnum;
  386. }
  387. function cristalmessage(cnum)
  388. {
  389.    var _loc2_ = _root.popmessage[0] + cnum + _root.popmessage[1];
  390.    getURL("FSCommand:cristalmsg",_loc2_);
  391.    trace(_loc2_ + "/" + cnum);
  392. }
  393. var pt = _root;
  394. var cakeArr = [];
  395. var stepArr = [];
  396. var cakeColor = [];
  397. var cakeColor2 = [];
  398. var initCX = pt.cakeList._x;
  399. var game_overstate = false;
  400. stopAllSounds();
  401. var gcnt = 0;
  402. var ccnt = 0;
  403. var itemnum = 10;
  404. var initTime = 150;
  405. _root.point = 0;
  406. var cakesp = 2.8;
  407. var caketime = 9500;
  408. var copynum = 0;
  409. _root.m3num = 0;
  410. _root.m4num = 0;
  411. _root.m5num = 0;
  412. gameStart();
  413. cakeStart();
  414. timeSpace = 0;
  415. _root.ts = getTimer();
  416. _root.timmer.onEnterFrame = function()
  417. {
  418.    var _loc3_ = (getTimer() - _root.ts) / 1000;
  419.    timeSec = initTime - Math.floor(_loc3_) + 1 + timeSpace;
  420.    if(timeSec == 0)
  421.    {
  422.       gameover();
  423.    }
  424.    this.gotoAndStop(timeSec);
  425. };
  426. gameSound("bgm");
  427. System.useCodepage = true;
  428. if(_root.xmldir == undefined)
  429. {
  430.    _root.xmldir = "../";
  431. }
  432. xmldoc = new XML();
  433. xmldoc.ignoreWhite = true;
  434. xmldoc.load(_root.xmldir + "cake.xml");
  435. xmldoc.onLoad = getXmlData;
  436. System.security.allowDomain("*");
  437.